package com.abuaziz.librarys.LanguageSample

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat.startActivity
import com.abuaziz.librarys.R
import com.abuaziz.librarys.base.AppBaseActivity
import com.ug_project.views.click
import com.ug_project.views.content
import kotlinx.android.synthetic.main.activity_language.*
import me.ezitku.base.extensions.language.EnumLanguage
import me.ezitku.base.extensions.language.currentLanguagePref

class LanguageActivity : AppBaseActivity() {


    /**
     * 1. Application 的 attachBaseContext 里面调用 languageContext函数
     * 2. Activity 的 attachBaseContext 里面调用 languageContext函数
     * 3.  切换语言后 最好退出应用（重新启动应用）
     *
     */

    override fun getLayoutResId(): Int {
        return R.layout.activity_language
    }

    override fun init(view: View?, savedInstanceState: Bundle?) {

        ug.click {
            currentLanguagePref = EnumLanguage.ئۇيغۇرچە.language
            startNext()
//            finish()
        }

        zh.click {
            currentLanguagePref = EnumLanguage.中文.language
//            finish()
            startNext()
        }
        en.click {
            currentLanguagePref = EnumLanguage.English.language
            startNext()
//            finish()
        }

        get_string.click {
            //            resources_content.content = getString(R.string.this_is_resources_content)
            resources_content.content = applicationContext.getString(R.string.this_is_resources_content)
        }

    }


    fun startNext(){
        startActivity(Intent(this,LanguageActivity::class.java))
        finish()
    }

}